# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: André Klitzing <aklitzing@gmail.com>
# Maintainer: André Klitzing <aklitzing@gmail.com>
pkgname=flatpak
pkgver=1.8.1
pkgrel=0
pkgdesc="Application deployment framework for desktop apps"
url="https://flatpak.org"
arch="all"
license="LGPL-2.1-or-later"
depends="bubblewrap xdg-dbus-proxy"
makedepends="glib-dev libarchive-dev libsoup-dev libcap-dev polkit-dev
	libxau-dev ostree-dev>=2018.08 fuse-dev json-glib-dev
	libgcab-dev appstream-glib-dev dconf-dev
	libseccomp-dev libxslt-dev gpgme-dev bison
	py3-parsing zstd-dev"
subpackages="
	$pkgname-dev
	$pkgname-lang
	$pkgname-dbg
	$pkgname-zsh-completion
	$pkgname-bash-completion
	"
install="flatpak.pre-install flatpak.pre-upgrade flatpak.post-install"
source="https://github.com/flatpak/flatpak/releases/download/$pkgver/flatpak-$pkgver.tar.xz
		musl-fixes.patch
		modules-load.conf
		"
options="suid !check" # Tests fail with no error message

# secfixes:
#   1.2.4-r0:
#     - CVE-2019-10063

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--sbindir=/usr/bin \
		--libexecdir=/usr/lib/$pkgname \
		--disable-static \
		--disable-documentation \
		--with-priv-mode=setuid \
		--with-system-bubblewrap \
		--with-system-helper-user=flatpak \
		--with-system-dbus-proxy \
		--enable-gdm-env-file
	make
}

check() {
	make -k check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/lib/systemd

	install -Dm644 "$srcdir"/modules-load.conf "$pkgdir"/usr/lib/modules-load.d/flatpak.conf
}

sha512sums="37c1b1a4c64cae06f94d6e2c9715c8db996fc66574abbc0d2f41d695e36e5ff8812121c1a704f4fb20b552ff9af8125314e4436b15a85f86dba2053c5ed477d8  flatpak-1.8.1.tar.xz
9287ed146bf71665aa436a2c2110cc5edc829a7b4a3e3190947580850fe9ecfd2bb6adb015c692af022d425fb5259390fcdcbd402e8b0d12ee5d2c1a1071ed4f  musl-fixes.patch
57d23d2778556eafc3035e6be575bf95b4032f123b35f2b1657eff5e7496de253173edc657f90531ee58e25673f4f27a5cd1cc76b14a038edb244f104a231771  modules-load.conf"
